package com.fearless.crm.settings.service.impl;

import com.fearless.crm.settings.dao.DicTypeDao;
import com.fearless.crm.settings.dao.DicValueDao;
import com.fearless.crm.settings.entity.DicType;
import com.fearless.crm.settings.entity.DicValue;
import com.fearless.crm.settings.service.DicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
 class DicServiceImpl implements DicService {
    @Resource
    private DicTypeDao dicTypeDao;

    @Resource
    private DicValueDao dicValueDao;


    public void test() {
        System.out.println("service对象创建成功");
    }

    public Map<String, List<DicValue>> getAll() {
        Map<String,List<DicValue>> map=new HashMap<>();

        //将字典类型列表取出
        List<DicType> dicTypeList=dicTypeDao.getTypeList();

        //将字典类型遍历
        for(DicType dt:dicTypeList){
            //取得每一种类型的字典类型编码
            String code=dt.getCode();

            //根据每一个字典类型来取得字典值列表
            List<DicValue> dicValueList=dicValueDao.getListByCode(code);
            map.put(code,dicValueList);
        }
        /*
        map:
        {"appellation",dicValueList
        "clueState",dicValueList
        "returnPriority",dicValueList
        "returnState",dicValueList
        "source",dicValueList
        "stage",dicValueList
        "transactionType",dicValueList
        }
         */

        return map;

    }



}
